home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_13_03
/
grant
/
random.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1994-12-22
|
451b
|
27 lines
#include <stdlib.h>
#include "random.h"
// Return a pseudo-random number from 0.0 upto,
// but not including, 1.0.
float Rand0UpTo1(void)
{
return rand() / (float)(RAND_MAX + 1.0);
}
// Return a pseudo-random number between 0.0 and
// 1.0 inclusive.
float Rand0To1(void)
{
return rand() / (float)RAND_MAX;
}
// Return TRUE at the specified probability.
GABool Flip(float Prob)
{
return Rand0To1() <= Prob;
}